import Vue from 'vue'
import VueRouter from 'vue-router'
import { BasicLayout } from '@/layouts'

Vue.use(VueRouter)
export const routerMap = [
  {
    path: '/',
    component: BasicLayout,
    redirect: '/login',
    children: [
      {
        path: '/login',
        name: 'MyLogin',
        component: () => import('../views/login/login.vue')
      }
    ],
    meta: {
      title: '运中餐厅智慧食堂'
    }
  },
  {
    path: '/index',
    name: 'SIndex',
    component: () => import('../views/index/index.vue'),
    meta: {
      title: '档口填报'
    }
  },
  {
    path: '/selectFillIn',
    name: 'SelectFillIn',
    component: () => import('../views/index/selectFillIn.vue'),
    meta: {
      title: '选择填报'
    }
  },
  {
    path: '/fullinRecord',
    name: 'FullInRecord',
    component: () => import('../views/index/fullInRecord.vue'),
    meta: {
      title: '填报记录'
    }
  },
  {
    path: '/preserveDishes',
    name: 'PreserveDishes',
    component: () => import('../views/index/preserveDishes.vue'),
    meta: {
      title: '菜品留存'
    }
  },
  {
    path: '/preserveApply',
    name: 'PreserveApply',
    component: () => import('../views/index/preserveApply.vue'),
    meta: {
      title: '留存填报'
    }
  },
  {
    path: '/preserveDetails',
    name: 'PreserveDetails',
    component: () => import('../views/index/preserveDetails.vue'),
    meta: {
      title: '留存明细'
    }
  },
  {
    path: '/mine',
    name: 'MineInfo',
    component: () => import('../views/my/mine.vue'),
    meta: {
      title: '个人中心'
    }
  },
  {
    path: '/password',
    name: 'PassWord',
    component: () => import('../views/my/password.vue'),
    meta: {
      title: '修改密码'
    }
  },
  {
    path: '/userRole',
    name: 'UserRole',
    component: () => import('../views/my/userRole.vue'),
    meta: {
      title: '角色切换'
    }
  },
  {
    path: '/applyDetails',
    name: 'applyDetails',
    component: () => import('../views/index/applyDetails.vue'),
    meta: {
      title: '申报明细'
    }
  },
  {
    path: '/library',
    name: 'Library',
    component: () => import('../views/newIndex/library.vue'),
    meta: {
      title: '填报统计'
    }
  },
  {
    path: '/stockIn',
    name: 'StockIn',
    component: () => import('../views/newIndex/stockIn.vue'),
    meta: {
      title: '待入库'
    }
  },
  {
    path: '/shockInRecord',
    name: 'ShockInRecord',
    component: () => import('../views/newIndex/shockInRecord.vue'),
    meta: {
      title: '填报入库记录'
    }
  },
  {
    path: '/siRecordDetails',
    name: 'SiRecordDetails',
    component: () => import('../views/newIndex/siRecordDetails.vue'),
    meta: {
      title: '入库明细'
    }
  },
  {
    path: '/stockOutLibrary',
    name: 'StockOutLibrary',
    component: () => import('../views/stockOut/stockOutLibrary.vue'),
    meta: {
      title: '出库统计'
    }
  },
  {
    path: '/stockOutRecord',
    name: 'StockOutRecord',
    component: () => import('../views/stockOut/stockOutRecord.vue'),
    meta: {
      title: '填报出库记录'
    }
  },
  {
    path: '/stockOutDetails',
    name: 'StockOutDetails',
    component: () => import('../views/stockOut/stockOutDetails.vue'),
    meta: {
      title: '出库明细'
    }
  },
  {
    path: '/supplierLibrary',
    name: 'SupplierLibrary',
    component: () => import('../views/supplier/supplierLibrary.vue'),
    meta: {
      title: '待供应'
    }
  },
  {
    path: '/supplierRecords',
    name: 'SupplierRecords',
    component: () => import('../views/supplier/supplierRecords.vue'),
    meta: {
      title: '供应记录'
    }
  },
  {
    path: '/rawMaterial',
    name: 'RawMaterial',
    component: () => import('../views/supplier/rawMaterial.vue'),
    meta: {
      title: '原材料记录'
    }
  },
  {
    path: '/editRawMaterial',
    name: 'EditRawMaterial',
    component: () => import('../views/supplier/editRawMaterial.vue'),
    meta: {
      title: '修改原材料'
    }
  },
  {
    path: '/addRawMaterial',
    name: 'AddRawMaterial',
    component: () => import('../views/supplier/addRawMaterial.vue'),
    meta: {
      title: '新增原材料'
    }
  },
  {
    path: '/changeRecord',
    name: 'ChangeRecord',
    component: () => import('../views/supplier/changeRecord.vue'),
    meta: {
      title: '修改记录'
    }
  },
  {
    path: '/supplierDetails',
    name: 'SupplierDetails',
    component: () => import('../views/supplier/supplierDetails.vue'),
    meta: {
      title: '供应明细'
    }
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: routerMap
})
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
export default router
